const Koa = require('koa')
const errorCatch = require('./middlewares/global-error-catch')
const parser = require('koa-bodyparser')
const error = require('./core/http-exception')

const classic = require('./app/router/v1/classic')
const user = require('./app/router/v1/user')
const token = require('./app/router/v1/token')
const book = require('./app/router/v1/book')

const app = new Koa()

global.errs = error
app.use(errorCatch)

app.use(parser())

app.use(classic.routes())
app.use(user.routes())
app.use(token.routes())
app.use(book.routes())


app.listen(3000, () => {
  console.log('app is running at port 3000')
})